package br.com.felix.fwt.error;


/**
 * Represents an error that ocurred during the application execution. It may be, for example, a input validation error, or a database access error.
 * Anyway, the thing is that this object carries the message to be sent to the user, instead of the message to help the programmar debug. 
 * */
public class ApplicationError {
	
	/**
	 * Message to be sent to the user.
	 * */
	private String message;
	
	/**
	 * Application Exception
	 * */
	private Exception exception;
	
	

	/**
	 * Constructor to be used when an Exception was generated, and the user must be notified.
	 * */
	public ApplicationError(String msg, Exception e) {
		this.message = msg;
		this.exception = e;
	}
	

	/**
	 * Constructor to be used when an error is detected before an Exception is thrown, and the user must be notified.
	 * */
	public ApplicationError(String msg) {
		this.message = msg;
		this.exception = null;
	}
	
	
	/**
	 * Constructor to be used when an Exception was generated, and the user must be notified.
	 * Displays the Exception message to the user.
	 * */
	public ApplicationError(Exception e) {
		this.message = e.getMessage();
		this.exception = e;
	}


	
	public Exception getException() {
		return exception;
	}


	
	public String getMessage() {
		return message;
	}
}
